package com.hencoder.hencoderpracticedraw1.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class Practice8DrawArcView extends View {


    private RectF rectF=new RectF(200,200,600,400);

    public Practice8DrawArcView(Context context) {
        super(context);
    }

    public Practice8DrawArcView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice8DrawArcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

//        练习内容：使用 canvas.drawArc() 方法画弧形和扇形

        toCenterArc(canvas);
        noCenterArc(canvas);

        lineAct(canvas);
    }


    private void toCenterArc(Canvas canvas){
        Paint paint=new Paint();

        canvas.drawArc(rectF,250f,95f,true,paint);

    }


    private void noCenterArc(Canvas canvas){
        Paint paint=new Paint();
        canvas.drawArc(rectF,15,150,false,paint);
    }

    private void lineAct(Canvas canvas){
        Paint paint=new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(1);
        canvas.drawArc(rectF,180,55,false,paint);
    }
}
